home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 398 / 398.xpi / chrome / forecastfox.jar / content / bindings.xml < prev    next >
Extensible Markup Language  |  2010-02-04  |  12KB  |  272 lines

  1. <?xml version="1.0"?>
  2.  
  3. <!--****************************************************************************
  4.   Copyright (c) 2008 Ensolis, LLC. All Rights Reserved.
  5.   ***************************************************************************-->
  6. <!DOCTYPE bindings SYSTEM "chrome://forecastfox/locale/forecastfox.dtd" >
  7.  
  8. <bindings xmlns="http://www.mozilla.org/xbl"
  9.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  10.           xmlns:xbl="http://www.mozilla.org/xbl">
  11.  
  12.   <!-- base binding everything extends -->
  13.   <binding id="ff-base">
  14.     <resources>
  15.       <stylesheet src="chrome://forecastfox/skin/bindings.css"/>
  16.       <script type="application/x-javascript" src="chrome://forecastfox/content/ping/tracker.js"/> 
  17.     </resources>
  18.   </binding>
  19.  
  20.   <!-- panel binding -->
  21.   <binding id="ff-panel" display="xul:button" extends="chrome://forecastfox/content/bindings.xml#ff-base">
  22.     <content>
  23.       <xul:image anonid="ff-panel-icon" class="ffpanel-icon" validate="always" xbl:inherits="src, width=imagewidth, height=imageheight"/>
  24.       <xul:label class="ffpanel-text" xbl:inherits="value=label,crop"/>          
  25.     </content>
  26.     <implementation>
  27.       <property name="label"
  28.                 onget="return this.getAttribute('label');"
  29.                 onset="this.setAttribute('label',val); return val;"/>
  30.       <property name="src"
  31.                 onget="return this.getAttribute('src');"
  32.                 onset="this.setAttribute('src',val); return val;"/>
  33.       <property name="imagewidth"
  34.                 onget="return this.getAttribute('imagewidth');"
  35.                 onset="this.setAttribute('imagewidth',val); return val;"/>
  36.       <property name="imageheight"
  37.                 onget="return this.getAttribute('imageheight');"
  38.                 onset="this.setAttribute('imageheight',val); return val;"/>              
  39.     </implementation>    
  40.   </binding>
  41.   
  42.   <!-- tooltip binding --> 
  43.   <binding id="ff-tooltip" extends="chrome://global/content/bindings/popup.xml#tooltip">
  44.     <resources>
  45.       <stylesheet src="chrome://forecastfox/skin/bindings.css"/>
  46.     </resources>
  47.     <content>
  48.       <xul:hbox class="fftooltip-box" flex="1">
  49.         <xul:vbox class="fftooltip-iconbox" align="center" pack="center"  xbl:inherits="display">
  50.           <xul:image anonid="ff-tooltip-icon" class="fftooltip-icon" validate="always" xbl:inherits="src, width=imagewidth, height=imageheight"/>
  51.         </xul:vbox>
  52.         <xul:vbox class="fftooltip-textbox" xbl:inherits="display">
  53.           <xul:label anonid="ff-tooltip-title" class="fftooltip-title" xbl:inherits="value=title,crop"/>
  54.           <xul:vbox anonid="ff-tooltip-labels"/>
  55.         </xul:vbox>
  56.         <xul:vbox class="fftooltip-adbox" align="center" pack="center">
  57.           <xul:image anonid="ff-tooltip-ad" class="fftooltip-ad" validate="always" xbl:inherits="src=adsrc, width=adwidth, height=adheight"/>
  58.         </xul:vbox>        
  59.       </xul:hbox>
  60.     </content>
  61.     <implementation> 
  62.       <property name="display"
  63.                 onget="return this.getAttribute('display');"
  64.                 onset="this.setAttribute('display',val); return val;"/>
  65.       <property name="title"
  66.                 onget="return this.getAttribute('title');"
  67.                 onset="this.setAttribute('title',val); return val;"/>
  68.       <property name="label"
  69.                 onget="return this.getAttribute('label');"
  70.                 onset="this.setAttribute('label',val); return val;"/>                
  71.       <property name="src"
  72.                 onget="return this.getAttribute('src');"
  73.                 onset="this.setAttribute('src',val); return val;"/>
  74.       <property name="imagewidth"
  75.                 onget="return this.getAttribute('imagewidth');"
  76.                 onset="this.setAttribute('imagewidth',val); return val;"/>
  77.       <property name="imageheight"
  78.                 onget="return this.getAttribute('imageheight');"
  79.                 onset="this.setAttribute('imageheight',val); return val;"/>
  80.       <property name="adsrc"
  81.                 onget="return this.getAttribute('adsrc');"
  82.                 onset="this.setAttribute('adsrc',val); return val;"/>
  83.       <property name="adwidth"
  84.                 onget="return this.getAttribute('adwidth');"
  85.                 onset="this.setAttribute('adwidth',val); return val;"/>
  86.       <property name="adheight"
  87.                 onget="return this.getAttribute('adheight');"
  88.                 onset="this.setAttribute('adheight',val); return val;"/>
  89.       <method name="displayLabel">
  90.         <body>
  91.           <![CDATA[            
  92.             var title = document.getAnonymousElementByAttribute(this, "anonid", "ff-tooltip-title");
  93.             if (title.value == "")
  94.               title.setAttribute("hidden", "true");
  95.             else
  96.               title.removeAttribute("hidden");
  97.             
  98.             var labels = document.getAnonymousElementByAttribute(this, "anonid", "ff-tooltip-labels");
  99.             while(labels.hasChildNodes())
  100.               labels.removeChild(labels.lastChild);
  101.               
  102.             if (!this.hasAttribute("label"))
  103.               return;
  104.               
  105.             var lbls = this.label.split("/n");       
  106.             for (var i=0; i<lbls.length; ++i) {
  107.               var lbl = document.createElement("label");
  108.               if (lbls[i].length > 60) {
  109.                 var splitpoint = lbls[i].substring(0, 60).lastIndexOf(" ");
  110.                 if (splitpoint > 0)
  111.                   lbls.splice(i, 1, lbls[i].substring(0, splitpoint), lbls[i].substr(splitpoint + 1));
  112.               };
  113.               lbl.setAttribute("value", lbls[i]);
  114.               labels.appendChild(lbl);
  115.             };
  116.           ]]>
  117.         </body>      
  118.       </method> 
  119.       <field name="_parser">null</field>
  120.       <property name="parser">
  121.         <getter>
  122.           <![CDATA[
  123.             if (!this._parser) {
  124.               var mgrService = Components.classes["@ensolis.com/forecastfox/manager-service;1"].
  125.                                getService(Components.interfaces.ffIManagerService)
  126.               this._parser = mgrService.parser;
  127.             }
  128.             return this._parser;
  129.           ]]>
  130.         </getter>
  131.       </property>
  132.       <method name="fillPopup">
  133.         <parameter name="panel"/>
  134.         <body>
  135.           <![CDATA[                          
  136.             // tooltip isn't enabled
  137.             var enabled = panel.getAttribute("tooltipenabled");
  138.             enabled = (enabled == "true");
  139.             if (!enabled)
  140.               return false;
  141.       
  142.             //set the tooltip attributes
  143.             this.title = panel.getAttribute("tooltiptitle");
  144.             this.label = panel.getAttribute("tooltiplabel");
  145.             this.display = panel.getAttribute("tooltipdisplay");
  146.             this.src = panel.getAttribute("tooltipsrc");
  147.             this.imagewidth = panel.getAttribute("tooltipwidth");
  148.             this.imageheight = panel.getAttribute("tooltipheight");
  149.             var adsrc = this.parser.getValue("ad", 0, "imagepath", null);
  150.             if (panel.getAttribute("tooltipad") == "true" && adsrc && adsrc != "N/A") {
  151.               this.adsrc = adsrc;
  152.               this.adwidth = this.parser.getValue("ad", 0, "imagewidth", null);
  153.               this.adheight = this.parser.getValue("ad", 0, "imageheight", null);
  154.               FFTracker.trackURL(this.parser.getValue("ad", 0, "track", null));
  155.             } else {
  156.               this.adsrc = "";
  157.               this.adwidth = 0;
  158.               this.adheight = 0;
  159.             }
  160.             this.displayLabel();  
  161.  
  162.             // fire the tracker event
  163.             if (panel.getAttribute("prefix") == "logo")
  164.               FFTracker.trackURL(this.parser.getValue("logo", 0, "tooltiptrack", null));
  165.             else
  166.               FFTracker.tooltipLoad(panel.getAttribute("prefix"));
  167.     
  168.             //show the tooltip
  169.             return true;
  170.           ]]>
  171.         </body>
  172.       </method>        
  173.     </implementation> 
  174.     <handlers>
  175.       <handler event="popupshowing">
  176.         <![CDATA[
  177.           var panel = document.tooltipNode;
  178.           return this.fillPopup(panel);
  179.         ]]>
  180.       </handler>      
  181.     </handlers>
  182.   </binding>
  183.     
  184.   <!-- header no content binding -->
  185.   <binding id="ff-header" extends="chrome://forecastfox/content/bindings.xml#ff-base">
  186.     <content>
  187.       <xul:box class="ffheader-box" xbl:inherits="align=headeralign, pack=headerpack, orient=headerorient, dir=headerdir" flex="1">
  188.         <xul:description class="ffheader-text" xbl:inherits="value=title,crop"/>
  189.       </xul:box>          
  190.     </content>
  191.     <implementation>
  192.       <property name="title"
  193.                 onget="return this.getAttribute('title');"
  194.                 onset="this.setAttribute('title',val); return val;"/>
  195.     </implementation>     
  196.   </binding>
  197.   
  198.   <!-- header content binding -->
  199.   <binding id="ff-header-complex" extends="chrome://forecastfox/content/bindings.xml#ff-base">
  200.     <content>
  201.       <xul:box class="ffheader-box" xbl:inherits="align=headeralign, pack=headerpack, orient=headerorient, dir=headerdir" flex="1">
  202.         <children/>
  203.       </xul:box>                  
  204.     </content>
  205.   </binding>
  206.   
  207.   <!-- link binding -->
  208.   <binding id="ff-link" display="xul:button" extends="chrome://forecastfox/content/bindings.xml#ff-base">
  209.     <content>
  210.       <xul:label class="fflink-text" xbl:inherits="value=label,crop,tooltiptext"/>          
  211.     </content> 
  212.     <implementation implements="nsIAccessibleProvider">
  213.       <field name="_mgrSvc">null</field>
  214.       <constructor>
  215.         const Cc = Components.classes;
  216.         const Ci = Components.interfaces;
  217.         this._mgrSvc = Cc["@ensolis.com/forecastfox/manager-service;1"].getService(Ci.ffIManagerService);
  218.       </constructor>
  219.       <destructor>
  220.         this._mgrSvc = null;
  221.       </destructor>      
  222.       <property name="accessible">
  223.         <getter>
  224.           <![CDATA[
  225.             const Cc = Components.classes;
  226.             const Ci = Components.interfaces;
  227.             var acSvc = Cc["@mozilla.org/accessibilityService;1"].getService(Ci.nsIAccessibilityService);
  228.             return acSvc.createXULLinkAccessible(this);
  229.           ]]>
  230.         </getter>
  231.       </property>
  232.       <property name="label"
  233.                 onget="return this.getAttribute('label');"
  234.                 onset="this.setAttribute('label',val); return val;"/>      
  235.       <property name="href"
  236.                 onget="return this.getAttribute('href');"
  237.                 onset="this.setAttribute('href', val); return val;"/>
  238.       <property name="from"
  239.                 onget="return this.getAttribute('from');"
  240.                 onset="this.setAttribute('from', val); return val;"/>                
  241.       <property name="partner">
  242.         <setter>
  243.           <![CDATA[
  244.             if (val)
  245.               this.setAttribute("partner", "true");
  246.             else
  247.               this.setAttribute("partner", "false");
  248.             return val;
  249.           ]]>
  250.         </setter>
  251.         <getter>
  252.           return this.getAttribute("partner");
  253.         </getter>
  254.       </property>               
  255.     </implementation>
  256.     <handlers>
  257.       <handler event="keypress" keycode="VK_ENTER" action="this.click()" />
  258.       <handler event="keypress" keycode="VK_RETURN" action="this.click()" />
  259.       <handler event="click" button="0" count="1">
  260.       <![CDATA[
  261.         var url = this.href;
  262.         if (this.partner == "true")
  263.           url = url + "?partner=" + this._mgrSvc.partner;
  264.         var from = (this.from) ? this._mgrSvc.getPref("links." + this.from) :
  265.                                  "current";
  266.         this._mgrSvc.openLink(url, from);      
  267.       ]]>
  268.       </handler>
  269.     </handlers>
  270.   </binding>  
  271.  
  272. </bindings>